package com.cn.component;

import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.ScriptSource;
import org.springframework.scripting.support.ResourceScriptSource;
import org.springframework.stereotype.Component;
@Component
public class RedisToolScript {
	@Bean
    public DefaultRedisScript<Long> redisScript() {
        DefaultRedisScript<Long> redisScript = new DefaultRedisScript<Long>();
        redisScript.setScriptSource((ScriptSource) new ResourceScriptSource(new ClassPathResource("scripts/redisLua.lua")));
        redisScript.setResultType(Long.class);
        return redisScript;
    }
	
	@Bean
    public DefaultRedisScript<Long> redisNumScript() {
        DefaultRedisScript<Long> redisScript = new DefaultRedisScript<Long>();
        redisScript.setScriptSource((ScriptSource) new ResourceScriptSource(new ClassPathResource("scripts/redisNumLua.lua")));
        redisScript.setResultType(Long.class);
        return redisScript;
    }
}
